/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skat.comparators;

import rlpw.lang.Factory;
import skat.Card;

/**
 *
 * @author Ronny
 */
public abstract class Comparator implements java.util.Comparator<Card> {

    public abstract int getSortIndex(Card k);

    public int compare(Card o1, Card o2) {
        if (getSortIndex(o1) < getSortIndex(o2)) {
            return 1;
        } else {
            return -1;
        }
    }

    public static Comparator make() throws Exception {
        return Factory.make(Comparator.class);
    }

    public static Comparator make(String name) throws Exception {
        return Factory.make(Comparator.class, name);
    }
}
